import {mapMutations,mapActions,mapState} from 'vuex'
import _ from 'lodash'
export default {
    data(){
        return {
            vms:{},//页面组件vue实例
            models:{//模型
                entity:{}
            },
            dataSet:{//数据集
                tableData:[
                    {type:'abc',className:'def',values:{type:'a1'}}
                ],
                formData:{},
                treeData:[
                    {id:'a',parentId:'root',name:'a'},
                    {id:'b',parentId:'root',name:'b'},
                    {id:'a1',parentId:'a',name:'a1'},
                    {id:'a2',parentId:'a',name:'b2'},
                ],
                modalData:{}
            }
        }
    },
    provide () {
        return { 
          anc : this
        };
    },
    computed:{
        
    },
    created () {
        Object.keys(this.models).map(k=>{
            this.models[k]={
                clz:null,
                clzs:null
            }
            this.models[k].clz = this.$modelObject.create(k);
            this.models[k].clzs = this.$modelObject.create(k+'Collection');
        })
    },
    mounted(){
        this.$nextTick(()=>{
            if(process.env.NODE_ENV==='development'){
                console.log(this)
            }
        })
    },
    methods:{
        click(){
            let map = {}
            _.set(map,'a','a')
            let abc = this._subObject(map,'a.b',{v:'v1'})
            console.log(map)
            abc.v='v2'
            console.log(map)
            this.vms.form.validate()
            this.vms.modal.show =true

        },
        _showValues(clzs){
            if (clzs) {
                return clzs.records.map(d => {
                    return {
                        ...d,
                        ...d.values
                    }
                })
            } else {
                return [];
            }
        },
    }
}